﻿using System;
using System.ServiceModel;
using System.Collections.Generic;
using System.Linq;
using System.ComponentModel;

namespace Klinkby.MicroBus
{
    /// <summary>
    /// Defines the basic filter interface
    /// </summary>
    [ServiceContract]
    public interface IAsyncFilter : IDisposable
    {
        /// <summary>
        /// Process a message and wait for processing to complete
        /// </summary>
        /// <param name="message">Message to process</param>
        [OperationContract]
        void Process(IMessage message);
        /// <summary>
        /// Begin processing a message and return immediately
        /// </summary>
        /// <param name="message">Message to process</param>
        /// <param name="state">State object passed when processing completes 
        /// and <see cref="M:ProcessCompleted"/> is raised</param>
        /// <returns>A method that can be called to cancel the operation (currently unsupported).</returns>
        Action ProcessAsync(IMessage message, object state);
        /// <summary>
        /// Raised when async processing completes
        /// </summary>
        event EventHandler<ProcessCompletedEventArgs> ProcessCompleted;
    }    
}
